<template>
    <a-form ref="formRef" :model="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }">
        <a-form-item label="企业名称" :rules="rules.name" name="name">
            <a-input v-model:value="form.name" placeholder="请输入企业名称" />
        </a-form-item>
        <a-form-item label="联系人" :rules="rules.linkMan" name="linkMan">
            <a-input v-model:value="form.linkMan" placeholder="请输入联系人" />
        </a-form-item>
        <a-form-item label="联系电话" :rules="rules.linkTelphone" name="linkTelphone">
            <a-input v-model:value="form.linkTelphone" placeholder="请输入联系电话" />
        </a-form-item>
        <a-form-item label="企业描述" name="des">
            <a-textarea v-model:value="form.des" placeholder="请输入企业描述" />
        </a-form-item>
        <a-form-item label="状态" :rules="rules.status" name="status">
            <Switch v-model:checked="form.status" />
        </a-form-item>
    </a-form>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { useForm } from '@iframe/tools/mixins/FormMixins'
import { Switch } from '@iframe/tools/components'
import { TelphoneRegular } from '@iframe/tools/utils/regular'

const { validate, getForm, setForm } = useForm()
const formRef = ref()
const form = reactive({
    status: 0
})
const rules = reactive({
    name: { required: true, message: '请输入企业名称' },
    linkMan: { required: true, message: '请输入联系人' },
    linkTelphone: [
        { required: true, message: '请输入联系电话' },
        { pattern: TelphoneRegular, message: '请正确输入手机号' }
    ]
})

defineExpose({ validate: validate(formRef), getForm: getForm(form), setForm: setForm(form) })
</script>
